package com.learn.spring.java_config;

import com.learn.spring.bean.Cat;
import com.learn.spring.bean.Dog;
import com.learn.spring.bean.Person;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author wangxing
 * @version 2020/6/12 12:04 Administrator
 */
@Configuration
public class MainLifeCycleConfig {
    //方法名称需要在对应的对象中定义相同的名称
    @Bean(name = "person", initMethod = "init", destroyMethod = "destroy")
    public Person getPerson() {
        return new Person();
    }

    @Bean("dog")
    public Dog getDog() {
        return new Dog();
    }

    @Bean("cat")
    public Cat getCat() {
        return new Cat();
    }
}
